package com.yanqu.road.logic.pb;

import com.yanqu.road.entity.player.UserCollection;
import com.yanqu.road.entity.player.UserCollectionPavilion;
import com.yanqu.road.pb.building.BuildingProto;

import java.util.List;

public class CollectionPb {

    public static BuildingProto.CollectionPavilionMsg.Builder parseCollectionPavilionMsg(UserCollectionPavilion userCollectionPavilion){
        if(null == userCollectionPavilion){
            return null;
        }
        BuildingProto.CollectionPavilionMsg.Builder msg = BuildingProto.CollectionPavilionMsg.newBuilder();
        msg.setLevel(userCollectionPavilion.getLevel());
        return msg;
    }

    public static BuildingProto.CollectionTempMsg.Builder parseCollectionTempMsg(UserCollection userCollection){
        if(null == userCollection){
            return null;
        }
        BuildingProto.CollectionTempMsg.Builder msg = BuildingProto.CollectionTempMsg.newBuilder();
        msg.setCollectionId(userCollection.getCollectionId());
        msg.setLevel(userCollection.getLevel());
        return msg;
    }

    public static BuildingProto.CollectionListMsg.Builder parseCollectionListMsg(List<UserCollection> userCollectionList){
        BuildingProto.CollectionListMsg.Builder listMsg = BuildingProto.CollectionListMsg.newBuilder();
        if(null != userCollectionList){
            for(UserCollection userCollection : userCollectionList){
                BuildingProto.CollectionTempMsg.Builder msg = parseCollectionTempMsg(userCollection);
                if(null != msg){
                    listMsg.addCollectionList(msg);
                }
            }
        }
        return listMsg;
    }
}
